<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./lib/vue.min-2.6.11.js"></script>
</head>

<body>
    <div id="app">
        <input type="button" value="浪起来" v-on:click="lang">
        <input type="button" value="别浪" v-on:click="stop">
        <!-- 绑定的 属性 值 在 vue 中发生变化 就会 重新渲染这个节点 -->
        <h3 v-text="msg"></h3>
    </div>
</body>
<script>
    const vm = new Vue({
        el: '#app',
        data: {
            msg: '猥琐发育 别浪~~~~~~!!!',
            intervalId: null
        },
        methods: {
            lang: function () {
                if (this.intervalId != null) return

                const that = this
                this.intervalId = setInterval(function () {
                    const start = that.msg.substring(0, 1)
                    const end = that.msg.substring(1)

                    that.msg = end + start
                },100)

                
            },
            stop: function () {
                    clearInterval(this.intervalId) // 当清空时间循环后 需要将 变量设置为 null
                    this.intervalId = null
                }
        }
    })





</script>

</html>